<!--
 * @Description: 
 * @Autor: Zhu_liangyu
 * @Date: 2020-06-13 11:07:59
--> 
<template>
  <editor class="tinymce" v-model="eidtor_content" :init="init"></editor>
</template>
<script>
import tinymce from "tinymce/tinymce";
import Editor from "@tinymce/tinymce-vue";
import "tinymce/themes/silver";
import "tinymce/icons/default/icons.min.js";

import "tinymce/plugins/image";
import "tinymce/plugins/link";
import "tinymce/plugins/code";
import "tinymce/plugins/codesample";
import "tinymce/plugins/table";
import "tinymce/plugins/lists";
import "tinymce/plugins/wordcount";
import "tinymce/plugins/preview";
import "tinymce/plugins/fullscreen";
import "tinymce/plugins/contextmenu";

import { toolbar, plugins } from "@/components/editor/tinymce-editor.js";

export default {
  components: {
    Editor
  },
  model: {
    prop: "content",
    event: "change"
  },
  props: {
    content: {
      type: String
    },
    height: {
      type: Number,
      default() {
        return 600;
      }
    },
    toolbar: {
      type: String,
      default() {
        return toolbar;
      }
    },
    plugins: {
      type: String,
      default() {
        return plugins;
      }
    }
  },
  data() {
    return {
      eidtor_content: this.content,
      init: {
        language_url: "/tinymce/langs/zh_CN.js", // 语言包的路径
        language: "zh_CN", //语言
        skin_url: "/tinymce/skins/ui/oxide", // skin路径
        height: this.height, //编辑器高度
        branding: false, //是否禁用“Powered by TinyMCE”
        menubar: false, //顶部菜单栏显示
        browser_spellcheck: true, // 拼写检查
        elementpath: false, //禁用编辑器底部的状态栏
        statusbar: false, // 隐藏编辑器底部的状态栏
        paste_data_images: true, // 允许粘贴图像
        plugins: this.plugins,
        toolbar: this.toolbar
      }
    };
  },
  watch: {
    eidtor_content: function(val) {
      this.$emit("change", val);
    },
    content: function(val) {
      this.eidtor_content = val;
    }
  }
};
</script>
